package com.guanbo.asm;

import org.objectweb.asm.ClassReader;
import org.objectweb.asm.ClassVisitor;
import org.objectweb.asm.ClassWriter;

import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;

public class Generator {

    public static void main(String[] args) throws IOException {
        ClassReader cr = new ClassReader("com/guanbo/asm/Test01");
        ClassWriter cw = new ClassWriter(ClassWriter.COMPUTE_MAXS);
        ClassVisitor cv = new MyClassVisitor2(cw);
        cr.accept(cv, ClassReader.SKIP_DEBUG);
        byte[] data = cw.toByteArray();
        File file = new File("G:\\WorkSpace\\myProject\\jvm_test\\asm\\src\\com\\guanbo\\asm\\Test01.class");
        FileOutputStream fo = new FileOutputStream(file);
        fo.write(data);
        fo.close();
        System.out.println("Generator run success!");

    }
}
